//---声明函数
function hello() {
    console.log('hello world function...')
}

function pf(i) {
    return i * i
}

//
// function sum(a, b) {
//     return a + b
// }

function sum(...a) {
    return a.length === 0 ? 0 : a.reduce((x, y) => x + y)
}

function getNums() {
    return [1, 2, 3]
}

// let [a, b, c] = getNums()
// console.log(a, b, c)
//
// let arr = [10, 20, 30, ...getNums()]
// console.log(arr)

function add(a = 0, b = 0) {
    return a + b
}

function max() {
    let num = 0
    if (arguments.length > 0) {
        let max = arguments[0]
        for (let i of arguments) {
            max = Math.max(max, i)
        }
        num = max
    }
    return num
}

console.log(max(10, 200, 5, 50, 15))

// console.log(add(6, 5))

// console.log(sum())
// console.log(sum(1, 2, 6, 10, 2, 50))


//调用执行函数
let ff = hello
ff()
console.log(pf(3), pf())
ff()

